#ifndef LUAWRAPPER_H
#define LUAWRAPPER_H

#include <lua.hpp>
#include <string>
#include <QString>
#include <QStringList>

class LuaWrapper
{
public:
  LuaWrapper();
  ~LuaWrapper();

  bool load(const std::string& filename);
  bool load(const QString& filename);
  bool load(const char* filename);

  bool getTableField(int tableIndex, const std::string& field, std::string& target);
  bool getTableField(int tableIndex, const std::string& field, QString& target);
  bool getTableField(int tableIndex, const std::string& field, int& target);
  bool getTableField(int tableIndex, const std::string& field, double& target);
  bool getTableTable(int tableIndex, const std::string& field);

  bool initTableIterator(); //table has to be on top of stack
  bool nextTableIteration(); //table has to be on top of stack
  bool safetostring(int index, std::string& target); //safe for iterators

  void printStack();

  void error(const char* fmt, ...);
  void warning(const char* fmt, ...);

  lua_State* mLua;
};

#endif
